//
//  ZYDevice.m
//  YiLin
//
//  Created by Zyark on 2018/6/3.
//  Copyright © 2018年 Zyark. All rights reserved.
//

#import "ZYDevice.h"

@implementation ZYDevice
- (instancetype)init
{
    self = [super init];
    if (self) {
        _isOpen = NO;
        _isLock = NO;
        _isTest = NO;
        _isConnect = NO;
        _deviceId = @"";
        _mac = @"";
        _model = @"";
        _name = @"";
        _temperature = @"";
        _pmExponent = @"";
        _pmQuality = @"";
        _tvoc = @"";
        _roomTemperature = @"0";
        _humidity = @"0";
        _formaldehyde = @"";
        _outHumidity = @"0";
        _outTemperature = @"0";
        _outPmExponent = @"";
        _outPmQuality = @"";
        _oxygen = @"";
        _filterCommon = @"";
        _filterPm = @"";
        _carbonDioxide = @"0";
    }
    return self;
}
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"deviceId" : @"id",
             @"name" : @"name",
             @"mac" : @"uuid",
             @"serverDeviceType" : @"type",
             @"windSpeedType" : @"windSpeed",
             @"vsModeType" : @"windPannelModel",
             @"workModeType" : @"workModel",
             @"curveType" : @"controlFlag",
             @"isLock" : @"lockStatus",
             @"isOpen" : @"powerStatus",
             @"model" : @"mode",
             @"curveId" : @"curveId",
             @"pmExponent" : @"inPm25",
             @"outPmExponent" : @"outPm25",
             @"carbonDioxide" : @"co2",
             @"tvoc" : @"tvoc",
             @"formaldehyde" : @"hcho",
             @"humidity" : @"indoorHumidityRatio",
             @"outHumidity" : @"outdoorHumidityRatio",
             @"outTemperature" : @"outTemp",
             @"roomTemperature" : @"inTemp",
             @"windSpeedIn100" : @"windSpeedIn100"
             };
}

-(void)setServerDeviceType:(NSUInteger)serverDeviceType{
    _serverDeviceType = serverDeviceType;
    switch (serverDeviceType) {
        case 1:
            _type = ZYDeviceTypeAirConditioning;
            break;
        case 2:
            _type = ZYDeviceTypeRadiantFloorHeating;
            break;
        case 3:
            _type = ZYDeviceTypeVentilationSystem;
            break;
        default:
            break;
    }
}

-(ZYWindSpeedIn100Type)windSpeedIn100Type{
    if(_windSpeedIn100 <= 1){
        _windSpeedIn100Type = ZYWindSpeedIn100TypeLow;
    }else if(_windSpeedIn100 >1 && _windSpeedIn100 <=5){
        _windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
    }else{
        _windSpeedIn100Type = ZYWindSpeedIn100TypeHeight;
    }
    return _windSpeedIn100Type;
}

-(void)setIsNewVS:(BOOL)isNewVS{
    _isNewVS = isNewVS;
    if(isNewVS){
        switch (self.windSpeedIn100Type) {
            case ZYWindSpeedIn100TypeLow:
                _windSpeedType = ZYWindSpeedTypeLow;
                break;
            case ZYWindSpeedIn100TypeMiddle:
                _windSpeedType = ZYWindSpeedTypeMiddle;
                break;
            case ZYWindSpeedIn100TypeHeight:
                _windSpeedType = ZYWindSpeedTypeHeight;
                break;
        }
    }
}

-(void)setTemperature:(NSString *)temperature{
    if([temperature floatValue] <=0 || [temperature floatValue] >=35){
        _temperature = @"0";
        return;
    }
    temperature = [NSString stringWithFormat:@"%.0f",[temperature floatValue]];
    _temperature = temperature;
}

- (void)setRoomTemperature:(NSString *)roomTemperature{
    if([roomTemperature floatValue] <=0 || [roomTemperature floatValue] >=35){
        _roomTemperature = @"0";
        return;
    }
    roomTemperature = [NSString stringWithFormat:@"%.0f",[roomTemperature floatValue]];
    _roomTemperature = roomTemperature;
}

-(void)setOutTemperature:(NSString *)outTemperature{
    outTemperature = [NSString stringWithFormat:@"%.0f",[outTemperature floatValue]];
    _outTemperature = outTemperature;
}

-(void)setHumidity:(NSString *)humidity{
    humidity = [NSString stringWithFormat:@"%.0f",[humidity floatValue]];
    _humidity = humidity;
}

-(void)setOutHumidity:(NSString *)outHumidity{
    outHumidity = [NSString stringWithFormat:@"%.0f",[outHumidity floatValue]];
    _outHumidity = outHumidity;
}

-(void)setFormaldehyde:(NSString *)formaldehyde{
    formaldehyde = [NSString stringWithFormat:@"%.0f",[formaldehyde floatValue]];
    _formaldehyde = formaldehyde;
}

@end
